﻿using System;
using System.Drawing;

namespace PlusPlusPaint.Tools
{
    /// <summary>
    /// Abstract base class for classes that want to store one VisualObjectLayer
    /// object.  It would make sense for this to be a different hierarchy than
    /// SketchAwareTool, but C# doesn't allow multiple inheritance. :(
    /// </summary>
    abstract class VisualObjectLayerStoringTool : StandardTool
    {
        #region properties
        protected Layers.VisualObjectLayer Layer
        {
            get;
            private set;
        }
        #endregion

        /// <summary>
        /// Associates the tool with the given layer.  Should only be called by
        /// the layer in question, with itself as argument, once it has been
        /// established that everyone is okay with working together this way.
        /// </summary>
        public override void GiveAccessToLayer(Layers.VisualObjectLayer l, Point p)
        {
            this.Layer = l;
        }

        /// <summary>
        /// Associates the tool with the given layer.  Should only be called by
        /// the layer in question, with itself as argument, once it has been
        /// established that everyone is okay with working together this way.
        /// 
        /// There is a significant chance this function is never required;  in
        /// that case, it should be removed as soon as possible.
        /// </summary>
        public override void GiveAccessToLayer(Layers.CompositeLayer l, Point p)
        {
            throw new Exception(
                "Internal error:  Layer does not match requirements (is composite)."
            );
        }
    }
}
